import { getFocusList } from '@/api/adv'
//状态
const state = {
  focusList: [],
  recommendList: [],
}
//异步行为
const actions = {
  //获取轮播图信息
  async getFocusListAsync({ commit }) {
    const res = await getFocusList()
    commit('UP_FOCUSLIST', res.focusList)
  },
  //获取今日推荐
  async getTodayRecommendAsync({ commit }) {
    const res = await getTodayRecommend()
    commit('UP_RECOMMEND_LIST', res.recommendList)
  },
}
//mutations给状态
const mutations = {
  UP_FOCUSLIST(state, payload) {
    state.focusList = payload
  },
  UP_RECOMMEND_LIST(state, payload) {
    state.recommendList = payload
  },
}
export default {
  namespaced: true,
  state,
  mutations,
  actions,
}
